package com.ittest.mapper.store;

import com.ittest.domain.store.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ProductMapper {

    //添加
    @Insert("insert into product values(#{id},#{productNum},#{productName},#{cityName},#{departureTime},#{productPrice},#{productDesc},#{productStatus})")
    int add(Product product);

    //修改
    @Update("update product set " +
            "  productNum=#{productNum},"+
            "  productName=#{productName},"+
            "  cityName=#{cityName},"+
            "  DepartureTime=#{departureTime},"+
            "  productPrice=#{productPrice},"+
            "  productDesc=#{productDesc},"+
            "  productStatus=#{productStatus}"+
            "  where id = #{id}"
    )
    int update(Product product);

    //删除
    int delete(String[] ids);

    //查询
    List<Product> findAll(String sname);

    //根据id查询
    @Select("select * from product where id = #{id}")
    @Results({
            @Result(id=true,column = "id",property = "id"),
            @Result(column ="productNum",property = "productNum"),
            @Result(column ="productName",property = "productName"),
            @Result(column ="cityName",property = "cityName"),
            @Result(column ="DepartureTime",property = "departureTime"),
            @Result(column ="productPrice",property = "productPrice"),
            @Result(column ="productDesc",property = "productDesc"),
            @Result(column ="productStatus",property = "productStatus"),
    })
    Product findById(String id);


    void open( String[] ids);

    void close( String[] ids);
}
